<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.eagle.commons.vo.tbl_PosOperatorDic"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>集团用户发票打印查询</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<jsp:include page="../common/easyui.jsp"></jsp:include>
	<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/util.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/print.js"></script>
	<script type='text/javascript' src="<%=request.getContextPath()%>/dwr/interface/PrintDwr.js"></script>
	 <script type="text/javascript">
	 <% tbl_PosOperatorDic posoper = (tbl_PosOperatorDic)session.getAttribute("posoper");
       	  Integer posID = posoper.getBL_PosID();
       %>
	 //查询该时间内的发票使用
	 $(function(){
	 $('#print').datagrid({
				iconCls:'icon-save',
				height:350,
				//pagination:true,
				autoRowHeight: false,
				striped: true,
				collapsible:true,
				rownumbers:true,
				//url:'cardConsumsAction!userJTPrintInfo.action',
				singleSelect:true,
				fitColumns:false,
				onClickRow:function(rowIndex, rowData){
				$("#pcardID").val(rowData.quserid);
				$("#pmon").val(rowData.qmon);
				$("#ptype").val(rowData.qOperType);
				},
				frozenColumns:[[
				{field:'quserName',title:'用户名称',width:100}
				]],
				columns:[[
				    {field:'quserid',title:'用户编号',width:100},
					{field:'qmon',title:'扣款月份',width:100},
					{field:'qMoney',title:'应扣款金额',width:70},
					{field:'qCmomey',title:'已转账金额',width:70},
					{field:'qEmomey',title:'未转账金额',width:70},
					{field:'qPmomey',title:'已打票据金额',width:100},
					{field:'id',title:'明细',width:60,align:'center',
					formatter: function(value,rowData,rowIndex){
						return "<a href='javascript:void(getDetail(8))' class='easyui-linkbutton' iconCls='icon-search' ><img src='<%=request.getContextPath()%>/js/themes/icons/search.png' border='0' title='明细'/></a>";
					   }
					},
					{field:'quPmomey',title:'待打印票据金额',width:100},
					{field:'do',title:'明细',width:60,align:'center',
					formatter: function(value,rowData,rowIndex){
						return "<a href='javascript:void(getDetail(5))' class='easyui-linkbutton' iconCls='icon-search' ><img src='<%=request.getContextPath()%>/js/themes/icons/search.png' border='0' title='明细'/></a>";
					   }
					},
					{field:'qOperType',title:'票据类型',width:100,
					 formatter: function(value,row,index){
				                      if (row.qOperType==1){
					                   	return '记账卡月结发票';
			                           } else if(row.qOperType==0) {
				                        return '储值卡月结发票 ';
			                           }
			              }
					}
				]]
				});
				
	$("#printMon").datebox({  
       		required:true,  
       		onSelect: function(date){  
       		  var y = date.getFullYear();  
						  var m = date.getMonth() + 1;  
						  if(m<10)m="0"+m;
 					  var d = date.getDate();  
       		 $("#printMon").datebox("setValue", y+"-"+m);
       		}  
  			 });  

				
	 });
	 function doSearch(){ 
	 $('#print').datagrid({
	   	url:'cardConsumsAction!userJTPrintInfo.action',
	 	queryParams:{  
          cardID: $('#cardID').val(),    
          mon:$("#printMon").datebox('getText'),
          userName:encodeURI($('#userName').val())
        }  
        })
		 //$('#print').datagrid('load',{    
         // cardID: $('#cardID').val(),    
          //mon:$("#printMon").datebox('getText'),
          //userName:encodeURI($('#userName').val())
        //});    
 	 }  
 	
 	//查询明细
 	function getDetail(type){
 	    var ptype=$("#ptype").val();
 		if(ptype==0 && type==5){//储值卡
 			type=7;
 		}
 		document.getElementById("state").value=type;
 		//var cardid=$("#pcardID").val();
		$("#pmon").val();
		$('#mydialog').show(); 
		$('#mydialog').dialog({ 
		collapsible: true, 
		minimizable: true, 
		maximizable: true
	    });
	    
	    $('#tt').datagrid({
	    url:"cardConsumsAction!getJTPrintDetail.action",
	 	queryParams:{  
            cardID:encodeURI($("#pcardID").val()),    
         	mon:$("#pmon").val(),
         	state:type,
         	userType:2
        }  
        })
		//$('#tt').datagrid('load',{    
		 //   cardID:encodeURI($("#pcardID").val()),    
         //	mon:$("#pmon").val(),
         //	state:type,
         //	userType:2
       //	});    
 	}
 	//打印明细信息
 	function printInfo(){
 		  var prtVa = document.getElementById('printDiv').innerHTML; 		 
		  window.printFrame.document.getElementById('forPrint').innerHTML=prtVa;
	 	  window.printFrame.focus();
		  window.printFrame.doPrint(); 
 	}
 	//导出明细信息
 	function exportInfo_1(){
 	 	 var cardID= encodeURI($("#pcardID").val());    
         var mon=$("#pmon").val();
         var state=$("#state").val();
 		 $.ajax({
				   type: "POST",
				   url: "cardConsumsAction!userPrintInfo.action",
				   //data:{"posRole.RoleID":idValue},
				    data:{"userType":1,"cardID":cardID,"mon":mon,"state":state},
				   async:false,
				   timeout:40000
				});
 	}
 	
 	function exportInfo(){
 	    var cardID=$("#pcardID").val();   
         	var mon=$("#pmon").val();
         	var  st=document.getElementById("state").value;
		window.location.href="cardConsumsAction!exportUserWaste.action?"+"cardID="+cardID+"&mon="+mon+"&state="+st+"&userType="+2;
 	}
	 </script>
	 
  </head>
  
  <body>
   <div id="searchDiv" class="easyui-panel"  title="发票打印——查询条件" style="background-color:#EBF2FF;" collapsible="true">
		<form id="searchForm" method="post" style="margin-top:10px" action="">
	           <table >
	           <tr>
	           		<td width="5%" align="right">
							<div style="font-family:微软雅黑;font-size:12px;">用户名称&nbsp;&nbsp;</div>
						</td>
						<td width="8%" align="left">
							<input  class="easyui-validatebox" data-options="required:true"  type="text"  id="userName" name="userName" style="width:200px;border:1px solid #ccc" />
						</td>
						
						<td width="5%" align="right">
							<div style="font-family:微软雅黑;font-size:12px;">卡号&nbsp;&nbsp;</div>
						</td>
						<td width="8%" align="left">
							<input  class="easyui-validatebox" data-options="required:true"  type="text"  id="cardID" name="cardID" style="width:200px;border:1px solid #ccc" />
						</td>
						<td width="5%" align="right">
							<div style="font-family:微软雅黑;font-size:12px;">扣款月份&nbsp;&nbsp;</div>
						</td>
						<td width="8%" align="left">
							<input class="easyui-datebox" data-options="required:true"  type="text"  id="printMon" name="printMon" style="width:120px;border:1px solid #ccc" />
						</td>
						
	           </tr>
					<tr>
						
					</tr>
					</table>
					<div align="center">
					<table >
					<tr></tr>
					<tr></tr>
					<tr>
						<td colspan="2" width="20%" >
							<table align="center">
								<tr>
									<td width="10%" align="center"> <a href="javascript:void(0)"  class="easyui-linkbutton" iconCls="icon-search"  onclick="doSearch()">查询</a>
									<a href="javascript:void(0)"  class="easyui-linkbutton" iconCls="icon-redo" onclick="$('#searchForm')[0].reset();" >重置</a>
                                    </td>   
								</tr>
							</table>
						</td>						
					</tr>
				</table>     
				</div>
		 </form>
	</div>
	 <div id="rs" class="easyui-panel"  title="查询结果" style="background-color:#EBF2FF;" collapsible="true">
	 <table id="print" style="width:auto;overflow:auto"></table>    
	 </div>
      <input id="pcardID" type="hidden"/>
    <input id="pmon" type="hidden"/>
    <input id="state" type="hidden"/>
    <input id="ptype" type="hidden"/>
    <div id="mydialog" style="display:none;padding:5px;width:800px;height:400px;" toolbar="#tb" title="消费明细"> 
    <div id="printDiv" style="padding:5px;width:100%;height:100%;overflow:auto">
    <table id="tt" class="easyui-datagrid" 
			style=""  fit="true"
			 data-options="rownumbers:false,singleSelect:true,showFooter:true">
			<thead>
				<tr>
					<th data-options="field:'exitTime',width:120,align:'center'">消费时间</th>
					<th data-options="field:'userName',width:120,align:'center'">用户名称</th>
					<th data-options="field:'VLP',width:80,align:'center'">车牌号码</th>
					<th data-options="field:'payCardID2',width:120,align:'center'">支付卡号</th>
					<th data-options="field:'entryStationName',width:80,align:'center'">入口站</th>
					<th data-options="field:'exitStationName',width:80,align:'center'">出口站</th>
					<th data-options="field:'useMoney',width:100,align:'left'">消费金额（元）</th>
				</tr>
			</thead>
	
		</table>
		 </div>
    </div>
    
    <div id="tb">
            <div>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true"  onclick="exportInfo();"><font class="STYLES1">导出</font></a> 	
          <!--  <a href="javascript:void(0)" class="easyui-linkbutton"iconCls="icon-print" plain="true" onclick="printInfo()"><font class="STYLES1">打印</font></a>  --> 
             <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-print" plain="true" onclick="CreateFormPage('使用明细打印', $('#tt'))">打印</a>
			</div>
		</div>
		
		 <iframe style="width:0;height:0;" src="<%=request.getContextPath()%>/jsp/common/webprint.jsp" id="printFrame" name="printFrame"></iframe> 
  </body>
</html>
